﻿//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
using System.Collections.Specialized; 
using System.Collections.Generic; 
using System.Collections.ObjectModel;

namespace Manageo 
{ 
    public class ObservableRangeCollection<T> : System.Collections.ObjectModel.ObservableCollection<T> 
    {
        
        public void AddRange(IEnumerable<T> collection) 
        { 
            foreach (var i in collection) Items.Add(i); 
            OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); 
        } 

        public void RemoveRange(IEnumerable<T> collection) 
        { 
            foreach (var i in collection) Items.Remove(i); 
            OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); 
        } 
 
        public void Replace(T item) 
        { 
            ReplaceRange(new T[] { item }); 
        } 
  
        public void ReplaceRange(IEnumerable<T> collection) 
        { 
            List<T> old = new List<T>(Items); 
            Items.Clear(); 
            foreach (var i in collection) Items.Add(i); 
            OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); 
        } 


        public ObservableRangeCollection() : base() { } 

        public ObservableRangeCollection(IEnumerable<T> collection) : base(collection) { } 
    } 
}
